﻿using System;
using SilverChart.Core.Service;

namespace SilverChart.Core.Configuration.Converter {
    [ServiceProvider(LayzeCreation=true, ServiceName="Default Double configuration converter", Singleton=true)]
    public class DoubleConverter : ConfigurationConverter<Double> {

        #region ConfigurationConverter<double> Members

        public bool Convert(String itemValue, out double value) {
            if (itemValue == null) {
                value = Double.NaN;
                return false;
            }
            if (!Double.TryParse(itemValue, out value)) {
                //throw new ArgumentException(itemName + "[" + itemValue + "]" + " is not a valid Double type");
                value = Double.NaN;
                return false;
            }
            return true;
        }

        #endregion
    }
}
